from pedestrian.extensions import db
from flask_login import UserMixin
from werkzeug.security import generate_password_hash, check_password_hash


class Auth(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    telephone = db.Column(db.String(15), unique=True)
    username = db.Column(db.String(20))
    password_hash = db.Column(db.String(20))
    mail = db.Column(db.String(20))
    solutionSafety = db.relationship('SolutionSafety', back_population='auth')
    solutionAllotment = db.relationship('SolutionAllotment', back_population='auth')


class SolutionSafety(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    time = db.Column(db.DateTime(6), unique=True)
    numbers = db.Column(db.Integer, unique=True)
    auth_id = db.Column(db.String(15), db.ForeignKey('auth.id'))
    auth = db.relationship('Auth', back_population='solutionSafety')


class SolutionAllotment(db.Model):
    id = db.Column(db.String(20), primary_key=True)
    time = db.Column(db.DateTime(6), unique=True)
    numbers = db.Column(db.Integer, unique=True)
    auth_id = db.Column(db.String(15), db.ForeignKey('auth.id'))
    auth = db.relationship('Auth', back_population='solutionAllotment')
